package pt.ua.helpdesk.client;

import pt.ua.helpdesk.client.TicketView.LoadTicketDataAsyncCallback;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 * Click handler that allow the user to view a ticket
 * @author Amigos do Noddy
 *
 */
public class TicketSolvedOnClick implements ClickListener 
{
	private Integer IDTicket;
	private Button btn;
	private Label lblStatus;
	/**
	 * Class constructor
	 * @param id Ticket id
	 */
	public TicketSolvedOnClick(Integer id, Button btn,Label lblStatus)
	{
		this.IDTicket = id;
		this.btn = btn ;
		this.lblStatus = lblStatus ;
	}
	
	/**
	 * Click listener. Loads the composite used
	 * to view a ticket
	 */
	public void onClick(Widget sender) 
	{
		btn.setEnabled(false);
		lblStatus.setText("Resolvido");
		ServiceTickets.Util.getInstance().setTicketAsSolved(IDTicket, new LoadTicketDataAsyncCallback(btn));
	}

}